package org.aspectsense.examples.adaptivemail;

import org.aspectsense.middleware.interfaces.MailingService;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;


public class Mailer implements BundleActivator {

	private ServiceRegistration serviceRegistration;
	private MailingService ms;

	public void start(BundleContext context) throws Exception {
		
		ms = new MailingServiceImpl();
		assert serviceRegistration == null;
	     serviceRegistration = context.registerService(MailingService.class.getName(), ms, null);
	 
	}



	public void stop(BundleContext context) throws Exception {
		  if(serviceRegistration != null)
	        {
	            serviceRegistration.unregister();
	            serviceRegistration = null;
	        }
	}

}
